package com.tjnmt.togo.utils.BaiduMapUtil;

import com.baidu.trace.LBSTraceClient;
import com.baidu.trace.OnStartTraceListener;
import com.baidu.trace.Trace;
import com.tjnmt.togo.R;
import com.tjnmt.togo.listener.TimeEntityListener;
import com.tjnmt.togo.utils.ApplicationUtils;
import com.tjnmt.togo.utils.MacUtil;
import com.tjnmt.togo.utils.ResourceManagerUtil;

/**
 * 鹰眼轨迹工具类。
 * 该类不适合用静态方法。
 */
public class TraceUtil {

    private static final LBSTraceClient client;
    private static final long SERVICE_ID;
    private static final String MAC;

    static {
        client = new LBSTraceClient(ApplicationUtils.getContext());
        //设置定位数据采集周期和打包周期。
        client.setInterval(5,5);
        SERVICE_ID = Long.parseLong(ResourceManagerUtil.getString(R.string.service_id));
        MAC = MacUtil.getMacAddress();
    }
    /*
    *开启轨迹服务。
    * */
    public static void startTrace(OnStartTraceListener onStartTraceListener){
        Trace trace = new Trace(ApplicationUtils.getContext(),SERVICE_ID,MAC,2);
        client.startTrace(trace,onStartTraceListener);
    }
    /*
    * 查询实时位置的方法一。
    * */
    public static void getLocation(){
        //查询实时轨迹
        client.queryRealtimeLoc(SERVICE_ID,new TimeEntityListener());
    }
}
